const path = require('path');
const IS_PROD = ['production', 'test'].includes(process.env.NODE_ENV)

function resolve(dir = '') {
    return path.join(__dirname, './src', dir);
}

module.exports = {
    productionSourceMap: false,
    lintOnSave: false,
    devServer: {
        hot: true,
        open: true,
        port: 8080,
        proxy: {
            '/api': {
                //target: 'http://127.0.0.1:3000',
                target: 'http://cdapi.klzhsq.cn',
                changeOrigin: true,
                pathRewrite: {
                    //'^/api': '/src/api/'
                    '^/api': ''
                }
            }
        }
    },
    chainWebpack: config => {
        config.plugins.delete('prefetch');
        config.plugins.delete('preload');
        config.resolve.symlinks(true);
    },
    configureWebpack: {
        resolve: {
            // alias: {
            //   core: resolve('core')
            // }
        },
        optimization: {
            runtimeChunk: {
                name: entrypoint => `runtime~${entrypoint.name}`
            },
            splitChunks: {
                minChunks: 2,
                minSize: 20000,
                maxAsyncRequests: 20,
                maxInitialRequests: 30,
                name: false
            }
        }
    },
    css: {
        // 是否使用css分离插件 ExtractTextPlugin
        extract: false,
        // 开启 CSS source maps?
        sourceMap: false,
        // css预设器配置项
        loaderOptions: {},
        // 启用 CSS modules for all css / pre-processor files.
        modules: false,
    },
    devServer: {
        public: '',
        disableHostCheck: true
    },
    publicPath: './',
};